﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;


namespace Isha.Web.Mvc
{
    public class ResourceDispatcher
    {
        public ResourceDispatcher()
        {

        }

        public static string Extention
        {
            get
            {
                return Path.GetExtension(IshaContext.Current.Request.URL);
            }
        }

        public string ContentType
        {
            get
            {
                return ResourceDispatcher.Extention == ".js" ? "text/javascript" :
                            ResourceDispatcher.Extention == ".css" ? "text/css" : "image/gif";
            }
        }

        public byte[] Bytes
        {
            get
            {
                string physicalpath = HttpContext.Current.Server.MapPath("~/Views/" + IshaContext.Current.Request.URL);
                byte[] bytes = File.ReadAllBytes(physicalpath);
                return bytes;
            }
        }
    }
}
